package com.legendshop.openportal.sdk.model.response;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.hash.Hash;
import lombok.Data;

import java.io.Serializable;
import java.util.*;

/**
 * @author jzh
 * @version 1.0.0
 * @title PickupTimeBO
 * @date 2023/6/29 16:12
 * @description： 取件时间
 */
@Data
public class OpenPickupTimeBO implements Serializable {

    private static final long serialVersionUID = -3436217296866983664L;

    /**
     * 时间：如：2023-06-29
     */
    private String dateName;

    /**
     * 日期，如：6月29日
     */
    private String timeName;

    /**
     * 星期，如：星期四
     */
    private String weekName;

    /**
     * 时间段item
     */
    private HashMap<String, ArrayList<PickupTimeItemBO>> items;

    /**
     * 时间段item
     */
    private List<PickupTimeItemBO> itemList;

    /**
     * 添加时间段项
     * @param name
     * @param itemBO
     */
    public void addItem(String name, PickupTimeItemBO itemBO) {
        if (CollUtil.isEmpty(this.items)) {
            this.items = new LinkedHashMap<>();
        }

        if (itemBO != null) {
            ArrayList<PickupTimeItemBO> pickupTimeItemBOS = this.items.get(name);
            if (null == pickupTimeItemBOS) {
                pickupTimeItemBOS = new ArrayList<>();
                this.items.put(name, pickupTimeItemBOS);
            }

            pickupTimeItemBOS.add(itemBO);
        }
    }

    /**
     * 添加时间段项
     * @param itemBO
     */
    public void addItem(PickupTimeItemBO itemBO) {
        if (CollUtil.isEmpty(this.itemList)) {
            this.itemList = new ArrayList<>();
        }

        if (itemBO != null) {
            this.itemList.add(itemBO);
        }
    }

    @Data
    public static class PickupTimeItemBO implements Serializable {

        private static final long serialVersionUID = -4890888286902763215L;

        /**
         * 时间段，如：09:00~11:00
         */
        private String name;

        /**
         * 开始时间，如：2023-06-29 09:00:00
         */
        private String startTime;

        /**
         * 结束时间，如：2023-06-29 11:00:00
         */
        private String endTime;
    }
}
